package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/2/6.
 */
@HttpInlet(Conn.API_INSURANCE_DUTYFEE)
public class InsureanceDutyfeeGet extends BaseAsyGet<List<InsureanceDutyfeeGet.DutyfeeEntity>> {

    public InsureanceDutyfeeGet(AsyCallBack<List<InsureanceDutyfeeGet.DutyfeeEntity>> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected List<InsureanceDutyfeeGet.DutyfeeEntity> parser(JSONObject object) {


        TOAST = object.optString("message");

        if (object.optInt("code") == 200) {

            JSONArray array = object.optJSONArray("data");

            List<InsureanceDutyfeeGet.DutyfeeEntity> lists = new ArrayList<>();

            for (int i = 0; i < array.length(); i++) {

                JSONObject entityObject = array.optJSONObject(i);

                DutyfeeEntity dutyfeeEntity = new DutyfeeEntity();

                dutyfeeEntity.id = entityObject.optString("id");
                dutyfeeEntity.title = entityObject.optString("title");
                dutyfeeEntity.fee = entityObject.optString("fee");

                lists.add(dutyfeeEntity);

            }

            return lists;

        }

        return null;

    }

    public static class DutyfeeEntity{

        public String id, title, fee;

    }
}
